<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<div class="span12">
	<h2>行业列表</h2>
	<hr>
	<c:if test="${message != null }">
		<div class="alert alert-error">
			<c:out value="${message }" />
		</div>
	</c:if>
	<form class="form-serach" action='<c:url value="/industry-manage/" />'
		method="get">
		<input type="text" class="input-medium search-query"
			placeholder="输入行业名" name="n">
		<button type="submit" class="bnt">查询</button>
	</form>
	<a href='<c:url value="/industry-manage/upload" />'>上传行业列表</a> &nbsp; |
	&nbsp;<a href='<c:url value="/industry-manage/add" />'>新增行业</a> &nbsp;
	| &nbsp;<a href="#" onclick="updateallprice()">更新所有行业的价格统计信息</a>
	<hr>
	<table class="table table-bordered table-hover">
		<thead>
			<tr>
				<th>No.</th>
				<th>行业名</th>
				<th>行业启动顺序</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="o" items="${result.listResult }" varStatus="s">
				<tr>
					<td><c:out value="${s.index + (result.pageNo - 1) * 20 + 1}" /></td>
					<td><c:out value="${o.industryName }" /></td>
					<td><c:forEach var="i" items="${o.correlatedIndustryList }"
							varStatus="t">
							<c:out value="${i.industryName}" />
							<c:if test="${!t.last }">
								&nbsp;-> &nbsp;
							</c:if>
						</c:forEach></td>
					<td><a
						href='<c:url value="/industry-manage/showupdate/${o.id }" />'>编辑</a>
						&nbsp; | &nbsp;<a id="deleteA"
						href='<c:url value="/industry-manage/delete/${o.id }" />'
						onclick="return confirm('确认删除?');">删除</a> &nbsp; | &nbsp;<a
						href='<c:url value="/industry-manage/${o.id }/stocklist" />'>股票列表维护</a>
						&nbsp; | &nbsp; <a href="#" onclick="updateprice(${o.id })">更新该行业的价格统计信息</a>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>

	<div class="pagination">

		<ul>
			<c:forEach var="p" items="${ result.paginateList}">
				<c:if test="${p == result.pageNo }">
					<li class="active"><span>${p }</span></li>
				</c:if>
				<c:if test="${p != result.pageNo }">
					<li><a href='<c:url value="/industry-manage/?p=${p }" />'><span>${p }</span></a></li>
				</c:if>

			</c:forEach>
		</ul>
	</div>

</div>

<script type="text/javascript">
	function updateallprice(){
		if(confirm("确定更新统计信息?"))
			$.post('<c:url value="/industry-manage/updateallprice" />', function(data){
				//alert(data);
			});
	}
	
	function updateprice(industryId){
		if(confirm("确定更新统计信息?"))
			$.post('<c:url value="/industry-manage/updateprice?industryId=" />' + industryId, function(data){
				//alert(data);
			});
	}
</script>


